﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data;
using MySql.Data.MySqlClient;
using Utilities.QuickSql;


namespace WindowsFormsApplication1
{
    public partial class configurateur : Form
    {
        MySqlDatabase db = new MySqlDatabase("localhost", "B2_CS2I", "motdepasse", "projets4");
        
        public configurateur()
        {
            InitializeComponent();

            devis a = new devis(comboMarque.Text.ToString(), comboModele.Text.ToString());
            this.comboMarque.Items.Add("Choisir une marque");

            Table marque = db.QueryTable("SELECT * FROM marque");
            foreach (Record r in marque)
                this.comboMarque.Items.Add(r.Values[1]);
                this.comboMarque.SelectedIndex = 0;


            
            

            
            this.comboModele.Items.Add("Choisir un modele");
            this.comboModele.SelectedIndex = 0;

            
            
        }

        private void comboMarque_SelectedIndexChanged(object sender, EventArgs e)
        {
           
            if (comboModele.Text.ToString() != "Choisir un modele")
            {
                comboModele.Items.Clear();
            }
            Table modele = db.QueryTable("SELECT * FROM modele INNER JOIN marque ON modele.id_marque = marque.id_marque WHERE marque.nom_marque = '" + comboMarque.Text.ToString() + "'");
            foreach (Record r in modele)
                this.comboModele.Items.Add(r.Values[1]);
            comboModele.Text = "Choisir un modele ";
        }

        private void comboModele_SelectedIndexChanged(object sender, EventArgs e)
        {


            //if (comboModele.SelectedItem != "")
            //{
            //    label4.Visible = true;
            //    comboFinition.Visible = true;
            //}
        }

        private void comboFinition_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboFinition.SelectedItem != " ")
            {
                label5.Visible = true;
                label6.Visible = true;
                rectangleShape1.Visible = true;
                rectangleShape2.Visible = true;
                rectangleShape3.Visible = true;
                rectangleShape4.Visible = true;
                rectangleShape5.Visible = true;
                rectangleShape6.Visible = true;
                rectangleShape7.Visible = true;
                rectangleShape8.Visible = true;
            }
        }

        private void rectangleShape1_Click(object sender, EventArgs e)
        {
            ovalShape1.BackColor = Color.White;
        }

        private void rectangleShape2_Click(object sender, EventArgs e)
        {
            ovalShape1.BackColor = Color.Black;
        }

        private void rectangleShape4_Click(object sender, EventArgs e)
        {
            ovalShape1.BackColor = Color.Red;
        }

        private void rectangleShape3_Click(object sender, EventArgs e)
        {
            ovalShape1.BackColor = Color.Blue;
        }

        private void rectangleShape5_Click(object sender, EventArgs e)
        {
            ovalShape1.BackColor = Color.Orange;
        }

        private void rectangleShape7_Click(object sender, EventArgs e)
        {
            ovalShape1.BackColor = Color.Gainsboro;
        }

        private void rectangleShape6_Click(object sender, EventArgs e)
        {
            ovalShape1.BackColor = Color.GreenYellow;
        }

        private void rectangleShape8_Click(object sender, EventArgs e)
        {
            ovalShape1.BackColor = Color.LightSteelBlue;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: cette ligne de code charge les données dans la table 'projets4DataSet.modele'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
            this.modeleTableAdapter.Fill(this.projets4DataSet.modele);
            // TODO: cette ligne de code charge les données dans la table 'projets4DataSet.marque'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
            this.marqueTableAdapter.Fill(this.projets4DataSet.marque);

        }

        private void quitterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
            //accueil fenAccueil = new accueil();
            //fenAccueil.Show();           
            
        }



    }
}
